<template>
  <div id="app">
    <add-book-dialog :visible.sync="addBookDialogVisible"></add-book-dialog>
    <book-list></book-list>
    
  </div>
</template>

<script>
import BookList from './AdminBookRecord_components/BookList.vue'
import AddBookDialog from './AdminBookRecord_components/AddBookDialog.vue'

export default {
  components: {
    BookList,
    AddBookDialog
  },
  data() {
    return { 
      addBookDialogVisible: false
    }
  },
  methods: {
    onBookAdded() {
      this.$refs.bookList.getBooksData(); // 刷新显示表单
    }
  },
  mounted() {
    this.$on('book-added', this.onBookAdded); // 监听 'book-added' 事件
  },
  beforeDestroy() {
    this.$off('book-added', this.onBookAdded); // 取消监听 'book-added' 事件
  }
  
}
</script>       